package com.example.orderflow.controller.view;

import com.example.orderflow.controller.base.ABaseController;
import com.example.orderflow.entity.vo.ResponseVO;
import com.example.orderflow.service.ApproveHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName AllOrdersController
 * @Description: 查看指定订单审批信息
 * @Since JDK 1.8
 * @Create 2024/7/12 16:07
 */

@RestController
public class OrderApprovalController extends ABaseController {

    @Autowired
    ApproveHistoryService approveHistoryService;


    /**
     * @create: 2024/7/12 16:07
     * @description: 查看指定订单审批信息
     * @return comments
     */
    @PostMapping("/SpecifiedOrderApprovalInformation")
    public ResponseVO specifiedOrderApprovalInformation(@RequestBody Map<String,String> map)
    {
        String orderId = map.get("orderId");

        if (approveHistoryService.findApproveHistoryByOrderId(orderId).size() == 0)
        {
            return getSuccessResponseVO(null);
        }

        return getSuccessResponseVO(approveHistoryService.findApproveHistoryByOrderId(orderId));
    }
}
